package com.ruoyi.core.service.impl;

import com.ruoyi.common.constant.TaskNameConstants;
import com.ruoyi.compensationManagement.service.ICompensationSalaryProjectManagementService;
import com.ruoyi.compensationManagement.service.ICompensationStaffpayrollService;
import com.ruoyi.core.service.TaskToBeDoneService;
import com.ruoyi.out.service.*;
import com.ruoyi.seal.service.ISealService;
import com.ruoyi.train.service.ITrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Yuan
 * @description 待审批任务实现类
 * @date 2022/11/8 15:36
 */
@Service
public class TaskToBeDoneServiceImpl implements TaskToBeDoneService {
    @Autowired
    private IProcTaskInstanceService procTaskInstanceService;
    @Autowired
    private IApplicationVerificationService applicationVerificationService;
    @Autowired
    private ISealService sealService;
    @Autowired
    private ITrainService trainService;
    @Autowired
    private ICompensationStaffpayrollService compensationStaffpayrollService;

    @Override
    public Map<String, Integer> selectTaskToBeDone() {
        Map<String, Integer> map = new HashMap<>();
        //获取外出待审批任务
        int outTaskCount = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.GO_OUT_APPROVAL, "out:goout:approvalList");
        //获取加班待审批任务
        int workOvertimeTaskCount = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.LEAVE_APPLICATION, "out:workOvertime:approvalList");
        //查询加班待核实任务
        int workOvertimeVerifyCount = applicationVerificationService.selectToBeVerifyCount();
        //查询加班最终确认任务
        int workOvertimeFinalAssureTaskCount = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.FINAL_APPROVAL_OF_OVERTIME_WORK, "out:workOvertime:finalApprovalList");
        //查询请假待审批任务
        int leaveTaskCount = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.ASK_FOR_LEAVE_APPROVAL, "out:leave:approvalList");
        //休假待审批任务
        int holidayTask = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.VACATION_APPROVAL, "out:leave:approvalList");
        //探亲假待审批任务
        int visitTaskCount = procTaskInstanceService.selectToBeApprovedTask(TaskNameConstants.VISIT_THE_EXAMINATION_AND_APPROVAL, "out:leave:approvalList");
        //TODO:2022-11-08 用印、培训、工资确认等待处理任务

        int sealDeptCount = sealService.selectDeptToBeApprovedTask();
        int sealMasterCount=sealService.selectMasterToBeApprovedTask();

        map.put("outTaskCount", outTaskCount);
        map.put("workOvertimeTaskCount", workOvertimeTaskCount);
        map.put("workOvertimeVerifyCount", workOvertimeVerifyCount);
        map.put("workOvertimeFinalAssureTaskCount", workOvertimeFinalAssureTaskCount);
        map.put("leaveTaskCount", leaveTaskCount);
        map.put("holidayTask", holidayTask);
        map.put("visitTaskCount", visitTaskCount);

        map.put("sealDeptCount", sealDeptCount);
        map.put("sealMasterCount", sealMasterCount);
        return map;
    }
}
